#include "RandomFunction.h"
#include "../Backpropagation/BackpropagationSynapse.h"
#include "../Helper.h"

using namespace NeuralPlusPlus::Core;

NeuralPlusPlus::Core::Initializers::RandomFunction::RandomFunction( double minLimit /*= 0*/, double maxLimit /*= 1*/ )
	{
	this->MinLimit = minLimit;
	this->MaxLimit = maxLimit;
	}

void NeuralPlusPlus::Core::Initializers::RandomFunction::Initialize( Layer *activationLayer )
	{
	Helper::ValidateNotNull(activationLayer, "layer");
	int neuronLength = activationLayer->NeuronsLength;
	for (int i=0;i<neuronLength;i++)
		{
		((ActivationNeuron*)(*activationLayer)[i])->Bias = Helper::GetRandom(MinLimit, MaxLimit);
		}
	}

void NeuralPlusPlus::Core::Initializers::RandomFunction::Initialize( Connector *connector )
	{
	int synapsesSize = connector->SynapsesLength;
	for(int j=0;j<synapsesSize;j++)
		{
		ISynapse *synapse = &(*connector->Synapses)[j];
		synapse->Weight = Helper::GetRandom(MinLimit, MaxLimit);
		}
	}